package zhoug.common.adapters.recycler2;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

/**
 * 错误View的基类
 * @Author 35574
 * @Date 2021/3/3
 * @Description
 */
public abstract class ErrorView {
    /**
     * 无数据提示
     */
    private CharSequence mErrorText = "发生错误了";


    public ErrorView() {
    }

    /**
     * 设置错误提示
     * @param errorText
     */
    public void setErrorText(CharSequence errorText) {
        this.mErrorText = errorText;
        if(getErrorTextView()!=null){
            getErrorTextView().setText(errorText);
        }
    }

    protected CharSequence getErrorText() {
        return mErrorText;
    }

    /**
     * 错误布局View
     * @param parent
     * @return
     */
    public abstract View getErrorView(ViewGroup parent);

    /**
     * 显示错误的文本TextView 是{@link #getErrorView(ViewGroup)}或者它的子View
     * @return
     */
    protected abstract TextView getErrorTextView();

}
